home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1193_debugging_fonts.rtf < prev    next >
Text File  |  1995-06-12  |  15KB  |  313 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\fmodern Courier;\f1\fmodern Ohlfs;}
  2. \paperw13740
  3. \paperh10140
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;\red84\green84\blue84;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc0\cf0 Q:  My fonts don't work with the AppKit! What can I do?\
  8. \
  9. A:  Yikes!! This is not an easy question to answer, as fonts are very complicated and any number of things could be wrong.  However, there are many things you can do to narrow the scope of the problem.\
  10. \
  11. There are a couple of ways in which a malformed or misinstalled PostScript font manifests itself.  Sometimes  the font name simply doesn't appear in the Font panel of an application.  Sometimes the new font name does appear, but when selected the display reads:\
  12. \
  13.  
  14. \f2\fs24\fc1\cf1     <<Unusable Font>>\
  15.  
  16. \f0\fs28\fc0\cf0     \
  17. And sometimes when a font is selected and previewed within the Font panel, the name of the font appears in the display, but it looks exactly like your default font (as a matter of fact, it is displayed in your default font). In this case, if you look in the console, you may likely see error messages which look like this:\
  18. \
  19.  
  20. \f1\fs20\fc1\cf1     Feb 15 12:36:57 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
  21.     Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setshared ]%%\
  22.     Feb 15 12:36:58 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
  23.     Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setfont ]%%\
  24.  
  25. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1     \
  26.  
  27. \f0\fs28 So, how do you fix it?\
  28. \
  29. First, there is a bug in the AppKit which may cause the erroneous 
  30. \f2\fs24 <<unusable font>>
  31. \f0\fs28  message. So the first thing that you should do when debugging a newly installed font is to make sure that you are not encountering this bug.\
  32. \
  33. The following steps will cause the bug:\
  34. \
  35.     • Add a font to 
  36. \b ~/Library/Fonts
  37. \b0  (or 
  38. \b /LocalLibrary/Fonts
  39. \b0 ).\
  40.     • In a shell, run 
  41. \b buildafmdir
  42. \b0  on that directory.\
  43. \
  44. There are a couple of other dependencies, but in general the new font will be 
  45. \f2\fs24 <<unusable>>
  46. \f0\fs28 .  Rebooting your system does not fix this—the directory is in a bad state. The user level work-around is:\
  47. \
  48.  
  49. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fi-980\li980\fc1\cf1 •    Move a font out of the directory.  Then move it back in (thus updating the modification time of the directory).\
  50. •     Remove the 
  51. \b .afmcache
  52. \b0 , 
  53. \b .fontdirectory
  54. \b0 , and 
  55. \b .fontlist
  56. \b0  files from the font directory.\
  57. •    Launch an application with a Font Panel.  Open the Font Panel.  An alert should be displayed indicating "Incorporating info about new fonts...".  All correct fonts in the directory should now be usable.\
  58.  
  59. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 \
  60. The underlying cause here is that in Releases 2 and 3 there are two programs that are run on the font directory:  
  61. \b buildafmdir
  62. \b0  (which creates 
  63. \b .fontdirectory
  64. \b0  and 
  65. \b .fontlist
  66. \b0 ) and 
  67. \b cacheAFMData
  68. \b0  (which creates 
  69. \b .afmcache
  70. \b0 ).   When the AppKit notices that there are new fonts, it does the right thing and runs both.  If you just run 
  71. \b buildafmdir
  72. \b0  by hand, you sometimes confuse the caching of the AFM data.  
  73. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 The only reason
  74. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 s
  75. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  you 
  76. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 might
  77. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  run 
  78. \b buildafmdir
  79. \b0  yourself 
  80. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 would be: (1) to debug
  81. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  font
  82. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 s,
  83. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  or
  84. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1  (2)
  85. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  
  86. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 because 
  87. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 the 
  88. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 A
  89. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 pp
  90. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 K
  91. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 it didn't run it for you
  92. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 , for some reason
  93. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 . This is how you run the 
  94. \b buildafmdir
  95. \b0  utility by hand:
  96. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 \
  97.  
  98. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 \
  99.  
  100. \f2\fs24     % buildafmdir ~/Library/Fonts\
  101.  
  102. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f1\fs22\fc0\cf0     \
  103.  
  104. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc1\cf1 The alert indicating "Incorporating info about new fonts..." may not be displayed immediately after launching an application. This is because the AppKit discovers new fonts lazily.  For applications that use the FontManager when they launch, new fonts are incorporated at launch.  For other applications, it doesn't happen until you open the Font Panel.  Opening the Font Panel always does this.\
  105. \
  106.  
  107. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 The best way to install a font is to just copy it into a font directory. In fact, it may also be best to remove 
  108. \b .fontdirectory
  109. \b0 , 
  110. \b .fontlist
  111. \b0 , and 
  112. \b .afmcache
  113. \b0  after installing a new font, and launching a new application.\
  114. \
  115.  
  116. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 Once you have verified that the Workspace Manager has properly recognized the newly installed font, you should determine whether or not the problems that you are having lie with the installation of the font.  A font—let's call it 
  117. \b Scrabble
  118. \b0 —should have the following file system structure: there should be 
  119. \i at least
  120. \i0  these three directories in 
  121. \b ~/Library/Fonts
  122. \b0 , or
  123. \b  /NeXTLibrary/Fonts
  124. \b0  or 
  125. \b /LocalLibrary/Fonts
  126. \b0  :\
  127. \
  128.  
  129. \fi-980\li980 •    
  130. \b Scrabble.font
  131. \b0 \
  132. •    
  133. \b afm
  134. \b0 \
  135. •    
  136. \b outline\
  137.  
  138. \b0\fi0\li0 \
  139. (If any font contains bitmap fonts, then a 
  140. \b bitmap
  141. \b0  directory is required as well.) The 
  142. \b Scrabble.font
  143. \b0  directory must contain all of the files which describe the font: 
  144. \b Scrabble and Scrabble.afm
  145. \b0 . 
  146. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 Any 
  147. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 R
  148. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 elease 2
  149. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1  or 3
  150. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1  software uses the PostScript outline, .afm
  151. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 ,
  152. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1  and .bepf files out of the containing .font directory, whereas the 1.0 software requires sym
  153. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc1\cf1 bolic 
  154. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc1\cf1 links in the outline, afm, and bitmap directories.\
  155.  
  156. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 \
  157. The file 
  158. \b Scrabble
  159. \b0  contains the PostScript program which describes the outline of each individual character. The file 
  160. \b Scrabble.afm
  161. \b0  contains the width information for each character. Both the outline file and the afm file contain the name of the font, and the font family among other information about the font. The file names 
  162. \i must
  163. \i0  match the font names which appear within the files.\
  164. \
  165. Taking our Scrabble example, in the Scrabble file we should see the following entries:\
  166. \
  167.  
  168. \f2\fs24\fc1\cf1     /FullName (Scrabble) readonly def\
  169.     /FamilyName (Scrabble) readonly def\
  170.     /FontName /Scrabble def\
  171.  
  172. \f0\fs28\fc0\cf0 \
  173. And in the Scrabble.afm file, we should see these entries:\
  174. \
  175.  
  176. \f2\fs24\fc1\cf1     FontName Scrabble\
  177.     FullName Scrabble\
  178.     FamilyName Scrabble\
  179.     Weight Medium\
  180.  
  181. \f0\fs28\fc0\cf0 \
  182. The names change a bit when you consider that many font families provide both bold and italic versions. Here's how a bold version of the Scrabble font would look:\
  183. \
  184. The directory would be named 
  185. \b Scrabble-Bold.font
  186. \b0 .\
  187. \
  188. The outline file would be named 
  189. \b Scrabble-Bold
  190. \b0 . It would contain the following entries:\
  191. \
  192.  
  193. \f2\fs24\fc1\cf1     /FullName (Scrabble Bold) readonly def\
  194.     /FamilyName (Scrabble) readonly def\
  195.     /FontName /Scrabble-Bold def\
  196.  
  197. \f0\fs28\fc0\cf0 \
  198. The afm file would be named 
  199. \b Scrabble-Bold.afm
  200. \b0 . It would contain the following entries:\
  201. \
  202.  
  203. \f2\fs24\fc1\cf1     FontName Scrabble-Bold\
  204.     FullName Scrabble Bold\
  205.     FamilyName Scrabble\
  206.     Weight Bold\
  207.  
  208. \f0\fs28\fc0\cf0 \
  209. It is important that the FullName be the FamilyName followed by whatever you want to appear in the second (Typeface) browser of the FontPanel.  In the above example, the word "Scrabble" appears in the Family browser in the FontPanel and the word "Bold" appears in the Typeface browser.  If the FullName of the font is exactly equal to the FamilyName, then the word that appears in the second column is the value of the Weight field in the afm file.  (This would have been the case for the example "FullName Scrabble" above.)\
  210. \
  211. And finally, on 1.0 you must link these files into the afm and outline directories. Use the following commands to do that:\
  212. \
  213.  
  214. \f2\fs24\fc1\cf1     % cd ~/Library/Fonts/afm\
  215.     % ln -s ../Scrabble.font/Scrabble.afm\
  216.     % cd ../outline\
  217.     % ln -s ../Scrabble.font/Scrabble\
  218.  
  219. \f0\fs28\fc0\cf0     \
  220. If your font contains bitmap files, you must link those files into the bitmap directory.\
  221. \
  222. Once you think that you have your fonts in order, 
  223. \fc1\cf1 you have to relaunch an application (and open the Font Panel) to take advantage of the new fonts.  When an application is launched, the AppKit can detect that new fonts have been added to the directory, and it runs 
  224. \b buildafmdir
  225. \b0  and 
  226. \b cacheAFMdata
  227. \b0 , as described above. \
  228. \
  229. Once you have correctly installed the font, there may still be some problems. Now, you must determine whether the problem lies within the PostScript outline file or with the afm file. The manner in which the font fails can sometime indicate which is the guilty party. If you are receiving an error in the Font panel says the font is unusable, then the afm file is guilty.\
  230. \
  231. Another way to determine whether the fault is with the outline file or with the afm file is to run the outline file through 
  232. \b pft
  233. \b0 .\
  234. \
  235. Here's how to do that (the commands that you type are in bold):\
  236. \
  237.  
  238. \f2\fs24     myhost> 
  239. \b pft
  240. \b0 \
  241.     Connection to PostScript established.\
  242.     
  243. \b (/Net/foobar/home/squiggle/Library/Fonts/Scrabble.font/Scrabble)
  244.  run
  245. \b0 \
  246.     %%[ Error: undefined; OffendingCommand:  ]%%\
  247.     
  248. \b quit
  249. \b0 \
  250.     pft: Connection to Window Server closed\
  251.     myhost> \
  252.  
  253. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f0\fs28\fc1\cf1 \
  254. You may have noticed that the full pathname of the font's outline file is required. 
  255. \b  
  256. \b0 The command
  257. \b  pft
  258. \b0  merely opens a connection to the WindowServer, which has been running since you booted your machine. The WindowServer is always launched from the root directory, and you must give the pathname from the current directory of the WindowServer, not your current directory.\
  259. \
  260. In the above 
  261. \b pft
  262. \b0  session the outline file had a syntax error in it, and the PostScript interpreter could not process it, producing an error. Of course, since PostScript error handling is archaic and does not inform you of the problem and where it exists, you must take further steps to discover just where that problem is. If you have it, you can use the DisplayTalk application to trace through the PostScript code, and it identifies the line on which the error occurs. Otherwise, you must resort to brute force method of debugging such as printing statements, and removing parts of the code a little bit at a time.\
  263. \
  264. While you are still connected to 
  265. \b pft
  266. \b0  you can look at the values of the font dictionary to see if things are as they should be. Refer to the Red Book (the PostScript Language Reference Manual) for more information on the structure of the font dictionary. Remember also that fonts are stored in the FontDirectory in the PostScript interpreter.\
  267. \
  268. Some common problems to look for when debugging your fonts:\
  269. \
  270. • Check for strange characters like 
  271. \f2\fs24 <ctrl-Z>
  272. \f0\fs28  or 
  273. \f2\fs24 <ctrl-D>
  274. \f0\fs28  characters at the end of the outline file. Often in the DOS/Windows or Macintosh worlds these characters are used to indicate end-of-job to the printer. However, it's not part of the PostScript language; it's really a printer protocol, and doesn't belong in a PostScript program.\
  275. \
  276. • Also, make sure that the carriage returns in the files are indeed carriage returns and not line feeds. Again, this is caused from the difference between file formats for DOS/Windows or Macintosh and those for UNIX.\
  277. \
  278. • Since these files are ASCII and partially human-readable, you can look at the files. Sometimes just by looking at the files carefully, you may notice something that doesn't look right, and which may indeed be the problem. Check to make sure that entries are consistently capitalized. For example, if you saw the following:\
  279. \
  280.  
  281. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f2\fs24\fc1\cf1     FullName Scrabble\
  282.     FamilyName Scrabble\
  283.     weight standard\
  284.     Notice \
  285.     ItalicAngle 0.0\
  286.  
  287. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f0\fs28\fc1\cf1 \
  288. There's a big clue that the weight entry is incorrect.\
  289. \
  290. • The Weight entry has a discrete set of valid values. They are "Ultra Light", "Thin", "Light", "Extra Light", "Book", "Regular", "Plain", "Roman", "Medium", "Demi", "Demi-Bold", "Semi-Bold", "Bold", "Extra Bold", "Heavy", "Heavyface", "Black", "Ultra", "UltraBlack", "Fat", "ExtraBlack", and "Obese".\
  291.  
  292. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 \
  293. For more information refer to the following documentation:\
  294. \
  295.  
  296. \i\fi-980\li980\fc1\cf1     Adobe Type 1 Font Format Book\
  297.     /NextLibrary/Documentation/NextDev/Concepts/Fonts.rtf (on-line in Digital Librarian)\
  298.     The Red Book (Level 1 and Level 2)\
  299.  
  300. \fi0\li0\fc0\cf0 \
  301.  
  302. \i0 or look at the fonts in /NextLibrary/Fonts for example fonts.\
  303.  
  304. \i \
  305.  
  306. \i0 QA746\
  307.  
  308. \i \
  309.  
  310. \i0 Valid for 1.0, 2.0, 3.0, 3.1\
  311. \
  312.  
  313.